using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace BouncinBall.Utility
{
    public class Position
    {
        Vector3 _pos;

        /// <summary>
        /// Get x,y coordinate of Position
        /// </summary>
        public Vector2 LateralPosition { get { return new Vector2(_pos.X, _pos.Y); } }

        /// <summary>
        /// Get z coordinate of Position
        /// </summary>
        public float Height { get { return _pos.Z; } }

        /// <summary>
        /// Get Position vector
        /// </summary>
        public Vector3 FullPosition { get { return _pos; } }

        #region Constructors

        public Position()
        {
            _pos = new Vector3();
        }

        public Position(Vector3 pos)
        {
            _pos = new Vector3(pos.X, pos.Y, pos.Z);
        }

        public Position(float x, float y, float z)
        {
            _pos = new Vector3(x, y, z);
        }

        #endregion Constructors

        public void ApplyVelocity(Velocity v, float elapsedSeconds)
        {
            _pos.X += v.Dx * elapsedSeconds;
            _pos.Y += v.Dy * elapsedSeconds;
            _pos.Z += v.Dz * elapsedSeconds;
        }

        public override string ToString()
        {
            return "Position:(" + _pos.X + "," + _pos.Y + ","  + _pos.Z + ")";
        }

        // Declare which operator to overload (+), the operand types, and return type
        public static Position operator +(Position p1, Position p2)
        {
            return new Position(p1.LateralPosition.X + p2.LateralPosition.X, 
                p1.LateralPosition.Y + p2.LateralPosition.Y, 
                p1.Height + p2.Height);
        }
    }
}
